<div class="right-side selection">
    <div class="btn-group">
        <div class="btn-group">
            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                正在进行
                <span class="caret"></span>
            </button>
            <ul class="dropdown-menu">
                <?php
                $i = 0;
                foreach($category as $value) {
                    if ($value['deadline'] - now() > 0) {
                        echo '<li><a href="'.base_url().'lists/search?id='.$value['id'].'">'.$value['category'].'</a></li>';
                        $i++;
                    }
                }
                if ($i == 0)
                    echo '<li><a href="#">暂无</a></li>';
                ?>
            </ul>
        </div>
        <div class="btn-group">
            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                已结束
                <span class="caret"></span>
            </button>
            <ul class="dropdown-menu">
                <?php
                $i = 0;
                foreach($category as $value) {
                    if ($value['deadline'] - now() < 0) {
                        echo '<li><a href="'.base_url().'lists/search?id='.$value['id'].'">'.$value['category'].'</a></li>';
                        $i++;
                    }
                }
                if ($i == 0)
                    echo '<li><a href="#">暂无</a></li>';
                ?>
            </ul>
        </div>
    </div>
</div>
<h1 id="titlename"><?=$headline;?></h1>
<div class="clear">
    <?php
    $having = FALSE;

    foreach($category as $value) {
        if ($value['deadline'] - now() > 0) {
            unset($lists);
            echo '<div class="clear">';
            echo '<h3 id="titlename">'.$value['category'].'</h3>';
            foreach($query as $val) {
                if ($value['category'] == $val['category']) {
                    $lists[] = $val;
                    $having = TRUE;
                }
            }
            echo '<div class="col-sm-6 col-md-6">';
            foreach($lists as $key => $element) {
                if ($key % 2 == 0)
                    echo '<a class="thumbnail" href="'.base_url().'detail?pid='.$element['pid'].'"><img src="'. base_url() . 'uploads/' . $element['filename'] . '" data-src="holder.js/100%x180" /></a>';
            }
            echo '</div>';
            echo '<div class="col-sm-6 col-md-6">';
            foreach($lists as $key => $element) {
                if ($key % 2 != 0)
                    echo '<a class="thumbnail" href="'.base_url().'detail?pid='.$element['pid'].'"><img src="'. base_url() . 'uploads/' . $element['filename'] . '" data-src="holder.js/100%x180" /></a>';
            }
            echo '</div>';
            echo '</div>';

        }
    }
    if (!$having) {
        echo '<div class="clear"><div class="alert alert-danger">目前没有任何正在进行的比赛的样子</div></div>';
    }
    ?>
    </div>
</div>